<div class="contentcontainer">
    <div class="headings altheading">
        <h2>Messages</h2>
    </div>

    <div class="contentbox">
<?php        if (isset($this->allMessages)&&($this->getId=='0')) { ?>
        <table width="100%">
            <thead>
                <tr>
                    <th>Name</th>
                    <th>Message</th>
                    <th>Actions</th>
                </tr>
            </thead>
            <tbody>
                <?php 
                    $data = $this->allMessages;
                                  
                 foreach ($data as $row) {
 ?>
                    <tr class="alt">
                        <td><a href="http://<?php echo $_SERVER['HTTP_HOST'] . '/control/'.$this->controller.'/'.$this->action.'/id/' . $row['id']; ?>"><?php echo substr($row['name'], 0, 20); ?></a></td>
                        <td><a href="http://<?php echo $_SERVER['HTTP_HOST'] . '/control/'.$this->controller.'/'.$this->action.'/id/' . $row['id']; ?>"><?php echo substr($row['text'], 0, 60) . ' ...'; ?></a></td>
                        <td>
                            <a href="http://<?php echo $_SERVER['HTTP_HOST'] . '/control/'.$this->controller.'/'.$this->action.'/id/' . $row['id'] . '/del/1/'; ?>" title=""><img SRC="/img/icons/icon_delete.png" alt="Delete" /></a>
                        </td>
                    </tr>
<?php }} elseif ($this->getId>'0')
{
    $data=$this->dataId;
    echo '<B>Name: </B> '.$data['name'].'<br>';
    echo '<B>Phone: </B> '.$data['phone'].'<br>';
    echo '<B>E-mail: </B> '.$data['mail'].'<br>';
    echo '<B>Message: </B> '.$data['text'].'<br><br>';
    echo '<a href="/control/'.$this->controller.'/">Back</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <a href="/control/'.$this->controller.'/'.$this->action.'/id/'.$data['id'].'/del/1/">Delete</a>';
}
        ?>
            </tbody>
        </table>
        <div style="clear: both;"></div>
    </div>

</div>